<template>
  <div class="list">
    <list class="listCont">
      <cell class="listContItem" v-for="(item, index) in longList" :key="index" @click="polling(item.SB_ID, item.JD, item.WD, index, item.SBXH, item.XXDZ, item.GSMC)" :class="[index === activeIndex ? 'active' : '']">
        <text class="text" :class="[index === activeIndex ? 'active' : '']">{{item.XXDZ}}{{item.MPH}}</text>
      </cell>
    </list>
  </div>
</template>
<script>
import store from '@/store/dmHome'
import { setCache } from '@/util/storageUtils'
import * as storage from '@/config/storageTypes'
import event from '@/net/event'

export default {
  name: 'list',
  data () {
    return {
      activeIndex: '-1',
      sbxq: {}
    }
  },
  methods: {
    polling (SB_ID, JD, WD, index, SBXH, XXDZ, GSMC) {
      this.activeIndex = index
      setCache(storage.CTCE_SBID, SB_ID)
      setCache(storage.CTCE_SBJWD, JSON.stringify({
        JD: JD,
        WD: WD,
        GSMC: GSMC,
        SBXH: SBXH,
        XXDZ: XXDZ,
        GSMC: GSMC
      }))
      setCache(storage.CTCE_INSTALL_TYPE, this.type)
      setCache(storage.CTCE_SBID_TYPE, JSON.stringify({
        sbid: SB_ID,
        type: this.type
      }))
      event.DetailsInfoSBDA(SB_ID, this.type).then(res => {
        setCache(storage.CTCE_SBXQ, res.result.dataitem)
        this.$router.open({
            name: 'pFootBar'
        })
      })
    }
  },
  computed: {
    longList () {
      return store.state.listData
    },
    type () {
      return store.state.type
    }
  }
}
</script>
<style scoped>
.list{
  width: 750px;
  position: absolute;
  flex: 1;
  background-color: white;
}
.listCont{
  width: 750px;
}
.listContItem{
  width: 750px;
  height: 100px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-left: 20.8px;
  border-bottom-color: #eee;
  border-bottom-width: 1px;
  border-bottom-style: solid;
  box-shadow: 0px -0.5px 1px 0px rgba(238,238,238,1), 0px 0.5px 1px 0px rgba(238,238,238,1);
}
.text{
  font-size: 29.1px;
  font-family:PingFangSC-Regular;
  color:rgba(102,102,102,1);
}
.active{
  color: #fff;
  background-color: rgba(62,175,252,1);
}
</style>

